package com.hitqz.robot.camera.dto;


import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class CameraParamDTO extends IEquipmentCmdParamsDto implements Serializable {


    private static final long serialVersionUID = 661234186276821041L;
    //ip
    private String ip;
    //通道号
    private Integer channel;

    //放大倍数
    private int absoluteZoom;
    //水平角
    private int azimuth;
    //俯仰角
    private int elevation;

    private boolean onlyChangeMode;
    //聚焦模式 0-自动，1-手动，2-半自动
    private byte byFocusMode;
    //聚焦值
    private int dwFocusPos;


    //水平参数 0-36.000
    private float fPan;
    //垂直参数 -90.000 – 270.000
    private float fTilt;
    //变倍参数 0-100000
    private float fZoom;
    //聚焦参数 聚焦范围：归一化0-100000
    private int dwFocus;
    //焦距范围：0-100000，单位：mm
    private int dwFocalLen;
    //镜头变倍配置类型 0-fZoom生效 1-dwFocalLen生效
    private int byZoomType;

    //预置点号（目前就大华使用预置点去设定参数）
    private int pointSn;

    public static List<EquipmentParamsDto> getOriginal(String ip, Integer channel){
        List<EquipmentParamsDto> paramsDtos = Lists.newArrayList();
        paramsDtos.add(CameraParamDTO.createParamsDto("absoluteZoom",  "absoluteZoom", "10", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("azimuth",  "azimuth", "0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("elevation",  "elevation", "0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("byFocusMode",  "byFocusMode", "2", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("fPan",  "fPan", "0.0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("fTilt",  "fTilt", "0.0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("zoom",  "zoom", "1.0", ""));
        return paramsDtos;
    }


    public static List<EquipmentParamsDto> getBack(String ip,Integer channel){
        List<EquipmentParamsDto> paramsDtos = Lists.newArrayList();
        paramsDtos.add(CameraParamDTO.createParamsDto("absoluteZoom",  "absoluteZoom", "10", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("azimuth",  "azimuth", "1800", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("elevation",  "elevation", "0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("byFocusMode",  "byFocusMode", "2", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("fPan",  "fPan", "180.0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("fTilt",  "fTilt", "0.0", ""));
        paramsDtos.add(CameraParamDTO.createParamsDto("zoom",  "zoom", "1.0", ""));
        return paramsDtos;
    }

    public static EquipmentParamsDto createParamsDto(String label, String key, String value, String valueFor) {
        EquipmentParamsDto dto = new EquipmentParamsDto();
        dto.setLabel(label);
        dto.setKey(key);
        dto.setValue(value);
        if (StrUtil.isNotEmpty(valueFor)) {
            dto.setValueFor(valueFor);
        }else {
            dto.setValueFor(value);
        }

        return dto;
    }


}
